﻿/*-----------------------------------------------
// File: BuffTrigger.cs
// Description: 
// Author: Shaobing	492057342@qq.com
-----------------------------------------------*/
using UnityEngine;
using System.Collections;
using Battle.Engine;

namespace Battle.Engine.LogicModel
{
    public class FBuffTrigger 
    {
        public string buffId;
        public double chance;
        public int buffSelect;
        public Buff buffTemplate;

        public EngineData engineData;
        public FBuffTrigger(string buffId, double triggerChance, int buffSelect, EngineData data) {
            this.engineData = data;
            this.buffId = buffId;
            this.chance = triggerChance * CommonMethod.tableAttributeConvert;
            this.buffSelect = buffSelect;
            buffTemplate = FBuffFactory.CreateBuff(buffId, data);
        }

        public bool isActive(double chanceperChange, double chanceChange)
        {
            if(engineData.random.value <= (chance*(1+ chanceperChange) + chanceChange))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }

}
